//影院详情
$(function(){

	var sWidth = $(".imgShowt").width(); //获取焦点图的宽度（显示面积）
	var len = $(".imgShowt ul li").length; //获取焦点图个数
	var index = 0;
	var picTimer;
	$(".imgNav li").mouseenter(function() {
		index = $(".imgNav li").index(this);
		showPics(index);
	}).eq(0).trigger("mouseenter");

	//本例为左右滚动，即所有li元素都是在同一排向左浮动，所以这里需要计算出外围ul元素的宽度
	$(".imgShowt ul").css("width",sWidth * (len));
	
	//鼠标滑上焦点图时停止自动播放，滑出时开始自动播放
	$(".imgShowt").hover(function() {
		clearInterval(picTimer);
	},function() {
		picTimer = setInterval(function() {
			showPics(index);
			index++;
			if(index == len) {index = 0;}
		},4000); //此4000代表自动播放的间隔，单位：毫秒
	}).trigger("mouseleave");
	
	//显示图片函数，根据接收的index值显示相应的内容
	function showPics(index) { //普通切换
		var nowLeft = -index*sWidth; //根据index值计算ul元素的left值
		//var titxt=$("#focus li img").eq(index-1).attr("alt");
		$(".imgShowt ul").stop(true,false).animate({"margin-left":nowLeft},300); //通过animate()调整ul元素滚动到计算出的position
		//$("#focus .btn span").removeClass("on").eq(index).addClass("on"); //为当前的按钮切换到选中的效果
		$(".imgNav li").removeClass("on").eq(index).addClass("on"); //为当前的按钮切换到选中的效果
	}

	$(".goods").find("ul").hide().eq(0).show();
	$(".tablist li").eq(0).addClass("on");
	$(".tablist li").click(function(){
		$(".tablist li").removeClass();
		$(this).addClass("on");
		var index=$(".tablist li").index(this);
		$(".goods").find("ul").hide().eq(index).show();
	})
	$(".tablist li a").click(function(event){
		event.preventDefault();
	})
	

});
(function($) {


	function ShowImages() {}
	ShowImages.target = ".show-images";
	ShowImages.$target = $(ShowImages.target);
	ShowImages.$list = ShowImages.$target.find(".con");
	ShowImages.$items = ShowImages.$target.find("ul");
	ShowImages.$btn = ShowImages.$target.find(".changing-over");

	ShowImages.now = 0; //起始索引.
	ShowImages.num = 1; //展示数量.
	ShowImages.itemWidth = ShowImages.$items.width(); //项目宽度.
	ShowImages.itemlength = ShowImages.$items.length; //项目长度.
	ShowImages.maxScroll = ShowImages.itemlength - ShowImages.num; //最大滚动.
	
	
	
	function ShowImages() {}
	ShowImages.target = ".details-img";
	ShowImages.$target = $(ShowImages.target);
	ShowImages.$list = ShowImages.$target.find(".con");
	ShowImages.$items = ShowImages.$target.find("ul");
	ShowImages.$btn = ShowImages.$target.find(".changing-over");

	ShowImages.now = 0; //起始索引.
	ShowImages.num = 1; //展示数量.
	ShowImages.itemWidth = ShowImages.$items.width(); //项目宽度.
	ShowImages.itemlength = ShowImages.$items.length; //项目长度.
	ShowImages.maxScroll = ShowImages.itemlength - ShowImages.num; //最大滚动.

	/**
	 * 初始化程序.
	 * @return {Object} this.
	 */
	ShowImages.init = function() {
		if ($(".con ul").length < 2) {
			$(".right").hide();
			$(".left").hide();

		}
		ShowImages.$btn.on("click", function() {

			var _$parent = $(this).parent(),
				_now = _$parent.data("now") || ShowImages.now,
				_itemWidth = ShowImages.itemWidth,
				_maxScroll = _$parent.data("maxScroll", _$parent.find("ul").length - ShowImages.num).data("maxScroll");

			if (ShowImages.$list.filter(":animated").length) { //在进行动画时屏蔽单击操作.
				return;
			}


			if ($(this).hasClass("left")) {
				$(".right").removeClass("gray");
				if (_now <= 1) {
					_now = 0;
					$(".left").addClass("gray");
				} else {
					_now--;


				}
			} else {
				$(".left").removeClass("gray");
				if (_now >= _maxScroll - 1) {
					_now = _maxScroll;
					$(".right").addClass("gray");
				} else {
					_now++;

				}
			}

			_$parent.data("now", _now);

			_$parent.find(".con").animate({
				"margin-left": -_now * _itemWidth
			}, "fast");

		});

		// return ShowImages.$target.map(function() {
		// 	$(this).find("ul").length > ShowImages.num
		// 		&& $(this).find(".changing-over.right").show();
		// });
	}

	ShowImages.init();
	
/*自适应屏幕宽度*/
function winResize() {
	var winWidth=$(window).width();
	if(winWidth<1200){
		$("body").addClass("w980");
	}
	else{
		$("body").removeClass();
	}
		sWidth = $(".pichow").width();
		$(".pichow ul").css("width",sWidth * (len));
		showPics(i_bnr);
		
		ShowImages.$list.css("margin-left","0");
		ShowImages.itemWidth = ShowImages.$items.width(); 
		ShowImages.init();
};

/*调用*/
winResize();
$(window).resize(function(){
	winResize();
});
})(jQuery);


/*banner划屏*/
var sWidth = $(".pichow").width();
var len = $(".pichow ul li").length;
var i_bnr = 0;
var picTimer;

for(var i=0;i<len;i++){
	$(".picture .litBtn").append("<a href='#'><span></span></a>")
}

$(".picture .litBtn a").mouseenter(function() {
	i_bnr = $(".picture .litBtn a").index(this);
	showPics(i_bnr);
}).eq(0).trigger("mouseenter");

$(".pichow ul").css("width",sWidth * (len));

$(".pichow").hover(function() {
	clearInterval(picTimer);
	},function() {
		picTimer = setInterval(function() {
		showPics(i_bnr);
		i_bnr++;
		if(i_bnr == len) {i_bnr = 0;}
	},4000);
}).trigger("mouseleave");

function showPics(index) {
	var nowLeft = -index*sWidth;
	$(".pichow ul").stop(true,false).animate({"margin-left":nowLeft},300);
	$(".picture .litBtn a").removeClass("on").eq(index).addClass("on");
}



/*banner划屏*/
/**var sWidtht = $(".imginformation").width();
var lent = $(".imginformation ul li").length;
var i_bnrt = 0;
var picTimer;

for(var i=0;i<lent;i++){
	$(".information .litBtntwo").append("<a href='#'><span></span></a>")
}

$(".information .litBtntwo a").mouseenter(function() {
	i_bnrt = $(".information .litBtntwo a").index(this);
	showPicstt(i_bnrt);
}).eq(0).trigger("mouseenter");

$(".imginformation ul").css("width",sWidtht * (lent));

$(".imginformation").hover(function() {
	clearInterval(picTimer);
	},function() {
		picTimer = setInterval(function() {
		//showPicstt(i_bnrt);
		i_bnr++;
		if(i_bnr == lent) {i_bnr = 0;}
	},4000);
}).trigger("mouseleave");**/

/**function showPicstt(index) {
	var nowLeft = -index*sWidtht;
	$(".imginformation ul").stop(true,false).animate({"margin-left":nowLeft},300);
	$(".information .litBtntwo a").removeClass("on").eq(index).addClass("on");
}**/









/*图片信息弹出*/
$(".movie_film_l").find(".hold").hide();
var sldTime;
$(".movie_film_l").hover(function(){
	var ngood=$(this);
	sldTime=setTimeout(function(){
		ngood.find(".hold").slideDown(400)
	},100);
},function(){
	clearTimeout(sldTime);
	$(this).find(".hold").slideUp(400);
})


$(".movie_exclusive").find(".movie_hold").hide();
var sldTime;
$(".movie_exclusive").hover(function(){
	var ngood=$(this);
	sldTime=setTimeout(function(){
		ngood.find(".movie_hold").slideDown(400)
	},100);
},function(){
	clearTimeout(sldTime);
	$(this).find(".movie_hold").slideUp(400);
})

$(function() {
	$('.watch').eq(0).find(".res_watch").show();
	$('.watch').eq(0).find(".res_xs").hide();
	$('.watch ').bind("mouseover",function(){
		$('.watch').find(".res_watch").hide();
		$('.watch').find(".res_xs").show();	
		$(this).find(".res_watch").show();
		$(this).find(".res_xs").hide();	
  
	})
});


$(function() {
	$('.movie_yptwo').eq(0).find(".res_watch").show();//初始化展开
	$('.movie_yptwo').eq(0).find(".res_xs").hide();//初始化隐藏
	$('.movie_yptwo ').bind("mouseover",function(){//鼠标事件
		$('.movie_yptwo').find(".res_watch").hide();//把上一个样式隐藏
		$('.movie_yptwo').find(".res_xs").show();	//把上一个样式默认	
		$(this).find(".res_watch").show();//show显示
		$(this).find(".res_xs").hide();	//$(this)的意思是相当于.m1_rebtwo li 获取这个的样式；hide隐藏
		})
});


$(function() {
	$('.watchtwo').eq(0).find(".res_watch").show();
	$('.watchtwo').eq(0).find(".res_xs").hide();
	$('.watchtwo ').bind("mouseover",function(){
		$('.watchtwo').find(".res_watch").hide();
		$('.watchtwo').find(".res_xs").show();	
		$(this).find(".res_watch").show();
		$(this).find(".res_xs").hide();	
  
	})
});





/*图片划屏*/
(function($) {
	

	
})(jQuery);


//选项卡 -
function setTab1(name,cursel,n){
	for(i=1;i<=n;i++){
		var menu=document.getElementById(name+i);  
		var con=document.getElementById("j_"+name+"_"+i);
		menu.className=i==cursel?"hover":"";
		con.style.display =i==cursel?"block":"none";
	}
}
			  
  function setTabsy(name,cursel,n){
   for(i=1;i<=n;i++){
	var menu=document.getElementById(name+i);
	var con=document.getElementById("yz_"+name+"_"+i);
	menu.className=i==cursel?"fs41_a":"";
	con.style.display=i==cursel?"block":"none";
   }
  }

//观影风向标-
//排行 -

//排行 -
/*jdMarquee*/
(function ($) {
	$.fn.jdMarquee = function (option, callback) {
		if (typeof option == "function") {
			callback = option;
			option = {};
		}
		var s = $.extend({deriction:"up", speed:10, auto:false, width:null, height:null, step:1, control:false, _front:null, _back:null, _stop:null, _continue:null, wrapstyle:"", stay:5000, delay:20, dom:"div>ul>li".split(">"), mainTimer:null, subTimer:null, tag:false, convert:false, btn:null, disabled:"disabled", pos:{ojbect:null, clone:null}}, option || {});
		var object = this.find(s.dom[1]);
		var subObject = this.find(s.dom[2]);
		var clone;
		if (s.deriction == "up" || s.deriction == "down") {
			var height = object.eq(0).outerHeight();
			var step = s.step * subObject.eq(0).outerHeight();
			object.css({width:s.width + "px", overflow:"hidden"});
		}
		if (s.deriction == "left" || s.deriction == "right") {
			var width = subObject.length * subObject.eq(0).outerWidth();
			object.css({width:width + "px", overflow:"hidden"});
			var step = s.step * subObject.eq(0).outerWidth();
		}
		var init = function () {
			var wrap = "<div style='position:relative;overflow:hidden;z-index:1;width:" + s.width + "px;height:" + s.height + "px;" + s.wrapstyle + "'></div>";
			object.css({position:"absolute", left:0, top:0}).wrap(wrap);
			s.pos.object = 0;
			clone = object.clone();
			object.after(clone);
			switch (s.deriction) {
			  default:
			  case "up":
				object.css({marginLeft:0, marginTop:0});
				clone.css({marginLeft:0, marginTop:height + "px"});
				s.pos.clone = height;
				break;
			  case "down":
				object.css({marginLeft:0, marginTop:0});
				clone.css({marginLeft:0, marginTop:-height + "px"});
				s.pos.clone = -height;
				break;
			  case "left":
				object.css({marginTop:0, marginLeft:0});
				clone.css({marginTop:0, marginLeft:width + "px"});
				s.pos.clone = width;
				break;
			  case "right":
				object.css({marginTop:0, marginLeft:0});
				clone.css({marginTop:0, marginLeft:-width + "px"});
				s.pos.clone = -width;
				break;
			}
			if (s.auto) {
				initMainTimer();
				object.hover(function () {
					clear(s.mainTimer);
				}, function () {
					initMainTimer();
				});
				clone.hover(function () {
					clear(s.mainTimer);
				}, function () {
					initMainTimer();
				});
			}
			if (callback) {
				callback();
			}
			if (s.control) {
				initControls();
			}
		};
		var initMainTimer = function (delay) {
			clear(s.mainTimer);
			s.stay = delay ? delay : s.stay;
			s.mainTimer = setInterval(function () {
				initSubTimer();
			}, s.stay);
		};
		var initSubTimer = function () {
			clear(s.subTimer);
			s.subTimer = setInterval(function () {
				roll();
			}, s.delay);
		};
		var clear = function (timer) {
			if (timer != null) {
				clearInterval(timer);
			}
		};
		var disControl = function (A) {
			if (A) {
				$(s._front).unbind("click");
				$(s._back).unbind("click");
				$(s._stop).unbind("click");
				$(s._continue).unbind("click");
			} else {
				initControls();
			}
		};
		var initControls = function () {
			if (s._front != null) {
				$(s._front).click(function () {
					$(s._front).addClass(s.disabled);
					disControl(true);
					clear(s.mainTimer);
					s.convert = true;
					s.btn = "front";
					if (!s.auto) {
						s.tag = true;
					}
					convert();
				});
			}
			if (s._back != null) {
				$(s._back).click(function () {
					$(s._back).addClass(s.disabled);
					disControl(true);
					clear(s.mainTimer);
					s.convert = true;
					s.btn = "back";
					if (!s.auto) {
						s.tag = true;
					}
					convert();
				});
			}
			if (s._stop != null) {
				$(s._stop).click(function () {
					clear(s.mainTimer);
				});
			}
			if (s._continue != null) {
				$(s._continue).click(function () {
					initMainTimer();
				});
			}
		};
		var convert = function () {
			if (s.tag && s.convert) {
				s.convert = false;
				if (s.btn == "front") {
					if (s.deriction == "down") {
						s.deriction = "up";
					}
					if (s.deriction == "right") {
						s.deriction = "left";
					}
				}
				if (s.btn == "back") {
					if (s.deriction == "up") {
						s.deriction = "down";
					}
					if (s.deriction == "left") {
						s.deriction = "right";
					}
				}
				if (s.auto) {
					initMainTimer();
				} else {
					initMainTimer(4 * s.delay);
				}
			}
		};
		var setPos = function (y1, y2, x) {
			if (x) {
				clear(s.subTimer);
				s.pos.object = y1;
				s.pos.clone = y2;
				s.tag = true;
			} else {
				s.tag = false;
			}
			if (s.tag) {
				if (s.convert) {
					convert();
				} else {
					if (!s.auto) {
						clear(s.mainTimer);
					}
				}
			}
			if (s.deriction == "up" || s.deriction == "down") {
				object.css({marginTop:y1 + "px"});
				clone.css({marginTop:y2 + "px"});
			}
			if (s.deriction == "left" || s.deriction == "right") {
				object.css({marginLeft:y1 + "px"});
				clone.css({marginLeft:y2 + "px"});
			}
		};
		var roll = function () {
			var y_object = (s.deriction == "up" || s.deriction == "down") ? parseInt(object.get(0).style.marginTop) : parseInt(object.get(0).style.marginLeft);
			var y_clone = (s.deriction == "up" || s.deriction == "down") ? parseInt(clone.get(0).style.marginTop) : parseInt(clone.get(0).style.marginLeft);
			var y_add = Math.max(Math.abs(y_object - s.pos.object), Math.abs(y_clone - s.pos.clone));
			var y_ceil = Math.ceil((step - y_add) / s.speed);
			switch (s.deriction) {
			  case "up":
				if (y_add == step) {
					setPos(y_object, y_clone, true);
					$(s._front).removeClass(s.disabled);
					disControl(false);
				} else {
					if (y_object <= -height) {
						y_object = y_clone + height;
						s.pos.object = y_object;
					}
					if (y_clone <= -height) {
						y_clone = y_object + height;
						s.pos.clone = y_clone;
					}
					setPos((y_object - y_ceil), (y_clone - y_ceil));
				}
				break;
			  case "down":
				if (y_add == step) {
					setPos(y_object, y_clone, true);
					$(s._back).removeClass(s.disabled);
					disControl(false);
				} else {
					if (y_object >= height) {
						y_object = y_clone - height;
						s.pos.object = y_object;
					}
					if (y_clone >= height) {
						y_clone = y_object - height;
						s.pos.clone = y_clone;
					}
					setPos((y_object + y_ceil), (y_clone + y_ceil));
				}
				break;
			  case "left":
				if (y_add == step) {
					setPos(y_object, y_clone, true);
					$(s._front).removeClass(s.disabled);
					disControl(false);
				} else {
					if (y_object <= -width) {
						y_object = y_clone + width;
						s.pos.object = y_object;
					}
					if (y_clone <= -width) {
						y_clone = y_object + width;
						s.pos.clone = y_clone;
					}
					setPos((y_object - y_ceil), (y_clone - y_ceil));
				}
				break;
			  case "right":
				if (y_add == step) {
					setPos(y_object, y_clone, true);
					$(s._back).removeClass(s.disabled);
					disControl(false);
				} else {
					if (y_object >= width) {
						y_object = y_clone - width;
						s.pos.object = y_object;
					}
					if (y_clone >= width) {
						y_clone = y_object - width;
						s.pos.clone = y_clone;
					}
					setPos((y_object + y_ceil), (y_clone + y_ceil));
				}
				break;
			}
		};
		if (s.deriction == "up" || s.deriction == "down") {
			if (height >= s.height && height >= s.step) {
				init();
			}
		}
		if (s.deriction == "left" || s.deriction == "right") {
			if (width >= s.width && width >= s.step) {
				init();
			}
		}
	};
})(jQuery);



$(function(){
    /*划屏滚动*/        

   $('#pichow').owlCarousel({
        items: 1,
        navigation: false,
        animateOut: 'fadeOut',
        loop: true,
        autoplay:true,
        autoplayTimeout:4000,
        autoplayHoverPause:true
    });
})

$("#ts").click(function(){
    $("#ts").attr("src", "/img/zzw1.gif");
	});
$(".details_zk").click(function() {
		if($(".h48").css("height")=="48px"){
			$(".h48").css('height','auto');
			$(".details_zk").html("- 收起");
		}
		else{
			$(".details_zk").html("+ 展开");
			$(".h48").css('height','48px');
		}
	});

